package com.yunji.coffee.entity.dto;

import com.yunji.cabinet.context.calculate.CabinetCalculate;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class CoffeeInfoDTO extends DeviceInfoDTO implements ICommonDeviceInfo{
    private static final long serialVersionUID = 1L;

    private List<CoffeeDetailInfoDTO> infoList;

    @Override
    public List<ICommonDeviceDetail> getDetailList() {
        List<ICommonDeviceDetail> detailList = new ArrayList<>();
        for (CoffeeDetailInfoDTO infoDTO : infoList) {
            ICommonDeviceDetail deviceDetail = new ICommonDeviceDetail() {
                @Override
                public Integer getOrdinal() {
                    return infoDTO.getOrdinal();
                }

                @Override
                public Integer getDistance() {
                    return infoDTO.getDistance();
                }

                @Override
                public Integer getQuantityAvailable() {
                    return infoDTO.getTissueStatus();
                }

                @Override
                public DeviceCellDetailDTO getCellDetail() {
                    return CabinetCalculate.getEventQuantity(CoffeeInfoDTO.this.getImei(),infoDTO.getDistance(),infoDTO.getOrdinal());
                }

                @Override
                public Integer getMotorStatus() {
                    return infoDTO.getMotorStatus();
                }
            };
            detailList.add(deviceDetail);
        }
        return  detailList;
    }
}
